package scau.erps.view.base;

import java.awt.Font;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

import org.jb2011.lnf.beautyeye.ch3_button.BEButtonUI;

import scau.erps.app.Erps;
import scau.erps.entity.Sand;
import scau.erps.service.SandService;
import scau.erps.service.impl.SandServiceImpl;
public abstract class ButtonPanel extends JPanel implements ActionListener{
	private static final long serialVersionUID = 1L;
	protected JButton[] btn = new JButton[32];
	public ButtonPanel(){
		String[] str = new String[]{"年度规划","支付应付税","订单竞价","登记订单","更新短贷","短贷还本付息","申请短贷","更新应付款","归还应付款",
				"更新原材料","原材料入库","下原材料订单","更新生产","完工入库","投资新生产线","生产线转产","变卖生产线","开始下一批生产","产品研发投资"
				,"更新应收款款","应收款收现","按订单交货","支付管理费","更新长贷","长贷还本付息","申请长贷","支付设备维修费","支付租金","折旧","新市场开拓",
				"ISO认证投资","关帐"};
		for (int i = 0; i < btn.length; i++) {
			btn[i] = new JButton(str[i]);
			btn[i].setFont(new Font("微软雅黑",Font.PLAIN,12));
			btn[i].addActionListener(this);			
		}
		int step = Integer.parseInt(Erps.getSand().getStep());
		int btnIndex = step-1;
		btn[btnIndex].setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green)); //当前步骤按钮呈现绿色		
	}
	
	/**
	 * 切换到下一步骤
	 */
	protected void changeStep(){
		Sand sand = Erps.getSand();
		int currentStep = Integer.parseInt(sand.getStep());
		int nextStep = currentStep+1;
		String step = Integer.toString(nextStep);
		sand.setStep(step);
		SandService sandService = Erps.getIocInstance().get(SandServiceImpl.class);
		sandService.updateSand(sand);
		this.btn[currentStep-1].setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.normal));
		this.btn[currentStep].setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.green));
	}

	

}
